﻿using System;
using System.Windows.Data;

namespace AnthStat.WPF.Applications.Converters
{
    public sealed class FlagTextConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return "N";
            }

            var zscore = (double)value;

            if (zscore >= 2)
            {
                return "H";
            }
            else if (zscore <= -2)
            {
                return "L";
            }
            else
            {
                return "N";
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    public sealed class FlagBrushConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return System.Windows.Media.Brushes.SlateGray;
            }

            var zscore = (double)value;

            if (zscore >= 3 || zscore <= -3)
            {
                return System.Windows.Media.Brushes.Tomato;
            }
            else if (zscore >= 2 || zscore <= -2)
            {
                return System.Windows.Media.Brushes.Orange;
            }
            else
            {
                return System.Windows.Media.Brushes.SlateGray;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
